import com.dst.dao.CategoryMapper;
import com.dst.dao.TeasMapper;
import com.dst.dao.UserMapper;
import com.dst.eneity.Category;
import com.dst.eneity.Tea;
import com.dst.eneity.User;
import com.dst.service.impl.TeaServiceImpl;
import com.dst.utils.MybatisUtils;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class test {
@Test
    public void test1(){
    SqlSession sqlSession = MybatisUtils.getSqlSession();
    UserMapper mapper = sqlSession.getMapper(UserMapper.class);
    User user = mapper.selectByNameAndPassword("aaa", "123456");
    System.out.println(user);
}
    @Test
    public void test2(){
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        TeasMapper mapper = sqlSession.getMapper(TeasMapper.class);
        List<Tea> teas = mapper.selectAll();
        teas.forEach(System.out::println);
    }
    @Test
    public void test3(){
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        TeasMapper mapper = sqlSession.getMapper(TeasMapper.class);
        Tea tea = mapper.selectById(1);
        System.out.println(tea);
    }
    @Test
    public void test4(){
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        CategoryMapper mapper = sqlSession.getMapper(CategoryMapper.class);
        List<Category> categories = mapper.selectCategory();
        categories.forEach(System.out::println);
    }
    @Test
    public void test5(){
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        TeasMapper mapper = sqlSession.getMapper(TeasMapper.class);
        List<Tea> teas = mapper.selectTeaAll("奶茶");
        teas.forEach(System.out::println);
    }
    @Test
    public void test6(){
        TeaServiceImpl teaService = new TeaServiceImpl();
        PageInfo<Tea> pageInfo = teaService.selectLimitAll(1, 4);
        System.out.println(pageInfo);
    }
    @Test
    public void test7(){
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        TeasMapper teasMapper = sqlSession.getMapper(TeasMapper.class);
        List<Tea> teaList = teasMapper.selectLikeAll("奶",6.0);
        System.out.println(teaList);
    }
}
